home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / ADA / GNAT / !gcc / adainc / 6 / ads / s-tastim < prev    next >
Text File  |  1996-02-12  |  6KB  |  123 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                     S Y S T E M . T A S K _ T I M E R                    --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                           (Compiler Interface)                           --
  9. --                                                                          --
  10. --                             $Revision: 1.4 $                             --
  11. --                                                                          --
  12. --    Copyright (C) 1991, 92, 93, 94, 1995 Free Software Foundation, Inc.   --
  13. --                                                                          --
  14. -- GNARL is free software; you can  redistribute it  and/or modify it under --
  15. -- terms of the  GNU General Public License as published  by the Free Soft- --
  16. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  17. -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
  18. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  19. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  20. -- for  more details.  You should have  received  a copy of the GNU General --
  21. -- Public License  distributed with GNARL; see file COPYING.  If not, write --
  22. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  23. -- MA 02111-1307, USA.                                                      --
  24. --                                                                          --
  25. -- As a special exception,  if other files  instantiate  generics from this --
  26. -- unit, or you link  this unit with other files  to produce an executable, --
  27. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  28. -- covered  by the  GNU  General  Public  License.  This exception does not --
  29. -- however invalidate  any other reasons why  the executable file  might be --
  30. -- covered by the  GNU Public License.                                      --
  31. --                                                                          --
  32. -- GNARL was developed by the GNARL team at Florida State University. It is --
  33. -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
  34. -- State University (http://www.gnat.com).                                  --
  35. --                                                                          --
  36. ------------------------------------------------------------------------------
  37.  
  38. --  Note: the compiler generates direct calls to this interface, via Rtsfind.
  39. --  Any changes to this interface may require corresponding compiler changes.
  40.  
  41. with Ada.Finalization;
  42.  
  43. with Ada.Calendar;
  44. --  Used for, Calendar.Time
  45.  
  46. with Ada.Real_Time;
  47. --  Used for, Real_Time.Time
  48. --            Real_Time.Time_Span
  49.  
  50. with System.Task_Clock;
  51. --  Used for, Stimespec
  52.  
  53. package System.Task_Timer is
  54.  
  55.    --  The contents of this package, with the exception of Delay_Block,
  56.    --  are internal to GNARL; Delay_Block is part of the compiler interface.
  57.    --  Unfortunately, they must be visible so that they can be accessed
  58.    --  from the body of Ada.Calendar.Delays and Ada.Real_Time.Delays,
  59.    --  and they must be in the same package as
  60.    --  Delay_Block so that they can be used to implement its finalization.
  61.  
  62.    type Delay_Block is limited private;
  63.    --  An object of this type is passed by the compiler to the Wait
  64.    --  entry of each delay object
  65.    --  (e.g. Ada.Calendar.Delays.Delay_Object.Wait).  This is used by
  66.    --  the delay object implementation to queue the delay request and
  67.    --  suspend the task.
  68.  
  69.    protected Timer is
  70.       pragma Priority (Priority'Last);
  71.  
  72.       --  The following Enqueue entries enqueue elements in wake-up time
  73.       --  order using a single timer queue (time in System.Real_Time.Time).
  74.  
  75.       entry Enqueue_Time_Span
  76.         (T : in Ada.Real_Time.Time_Span;
  77.          D : access Delay_Block);
  78.       entry Enqueue_Duration
  79.          (T : in Duration;
  80.          D : access Delay_Block);
  81.       entry Enqueue_Real_Time
  82.         (T : in Ada.Real_Time.Time;
  83.          D : access Delay_Block);
  84.       entry Enqueue_Calendar_Time
  85.         (T : in Ada.Calendar.Time;
  86.          D : access Delay_Block);
  87.       procedure Dequeue (D : access Delay_Block);
  88.       procedure Service (T : out System.Task_Clock.Stimespec);
  89.       function Empty return Boolean;
  90. --  private
  91. --  Private protected operations are not currently supported by the
  92. --  compiler.
  93.       procedure Time_Enqueue
  94.         (T : in System.Task_Clock.Stimespec;
  95.          D : access Delay_Block);
  96.    end Timer;
  97.  
  98. private
  99.  
  100.    --  Signal_Object provides a simple suspension capability.
  101.  
  102.    protected type Signal_Object is
  103.       pragma Priority (Priority'Last);
  104.       entry Wait;
  105.       procedure Signal;
  106.  
  107.    private
  108.       Open   : Boolean := False;
  109.    end Signal_Object;
  110.  
  111.    type Q_Link is access all Delay_Block;
  112.  
  113.    type Delay_Block is new Ada.Finalization.Limited_Controlled with record
  114.       S_O      : Signal_Object;
  115.       T        : System.Task_Clock.Stimespec;    --  wake up time
  116.       Next     : Q_Link;
  117.       Previous : Q_Link;
  118.    end record;
  119.  
  120.    procedure Finalize (Object : in out Delay_Block);
  121.  
  122. end System.Task_Timer;
  123.